<template>
    <section class="address-list-main base-main">
      <!--无地址-->
      <div class="none text-c fs14" v-if="addressData.length <= 0">
        <img src="../../assets/img/icon_none_address.png" alt="无收货地址">
        <p>暂无收货地址</p>
        <p>喜欢的商品要寄到哪里呢</p>
      </div>
      <!--无地址-->

      <!--有地址时-->
      <div class="address-list">
        <Address
          :addressData="addressData"
          @send-set="sendSet"
        ></Address>
      </div>
      <!--有地址时-->

      <!--新增按钮-->
      <div class="add-btn bgcFFF text-c">
        <span class="inline-block" @click="handleAddEdit">+ 新建收货地址</span>
      </div>
      <!--新增按钮-->
    </section>
</template>

<script type="text/ecmascript-6">
  import Address from '../../components/Address.vue'

  export default {
    components:{
      Address
    },
    data() {
      return {
        addressData:[
          {
            id:1,
            name:'test',
            tel:'13562452522',
            address:'北京市朝阳区',
            addressDetail:'详细地址',
            isDefault:true,
          },
          {
            id:2,
            name:'test2',
            tel:'13562452522',
            address:'北京市朝阳区',
            addressDetail:'详细地址',
            isDefault:false,
          },
        ],
      }
    },
    created(){
      console.log('00');
    },
    methods: {
      handleAddEdit(){
        this.$router.push({
          path:'/index/web/addressEditor'
        })
      },
      sendSet(obj){
        console.log('obj--', obj);
        switch (obj.type){
          case 1:
            this.sendEdit(obj.item);
            break;
          case 2:
            this.sendSetDefined(obj.item);
            break;
          case 3:
            this.sendDel(obj.item);
            break;
        }
      },
      //编辑
      sendEdit(obj){
        console.log('编辑--', obj);
      },
      //默认
      sendSetDefined(obj){
        console.log('设置默认--', obj);
      },
      //删除
      sendDel(obj){
        console.log('删除--', obj);
      },
    },
  }
</script>

<style scoped lang="scss">
  @import "../../assets/css/addressList";
</style>
